home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doExportClipArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.6 KB  |  182 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Nov, 1999
  22. //  Author:         bb
  23. //
  24. //    Procedure Name:
  25. //        doExportClipArgList
  26. //
  27. //    Description:
  28. //        Export a clip
  29. //
  30. //    Input Arguments:
  31. //    $version: The version of this option box.  Used to know how to 
  32. //    interpret the $args array.
  33. //  
  34. //    $args
  35. //    Version 1
  36. //  [0]     $editor: name of TraxEditor window or "" if none
  37. //    Version 2
  38. //  [0]     $editor: name of TraxEditor window or "" if none
  39. //  [1]     $clipName: name of clipName. If specified, this clip overrides the selected clips.
  40. //
  41. //
  42. global string $expClipEditor = "";
  43. global string $expClipName = "";
  44.  
  45. global proc int
  46. clipEditorExportClip(string $fileName, string $fileType)
  47. {
  48.     global string $expClipEditor;
  49.     global string $expClipName;
  50.  
  51.     if ($fileName == "") {
  52.         error("No file name was specified.");
  53.         return 0;
  54.     }
  55.  
  56.     if (`about -evalVersion`) {
  57.         $fileType = "mayaPLE";
  58.     }
  59.     
  60.     if ($fileType == "ma") {
  61.         $fileType = "mayaAscii";
  62.     } else if ($fileType == "mb") {
  63.         $fileType = "mayaBinary";
  64.     } else if ($fileType != "mayaBinary" && $fileType != "mayaAscii" && $fileType != "mayaPLE") {
  65.         error("Invalid file type for clip export: "+$fileType);
  66.         return 0;
  67.     }
  68.     
  69.     int $ii;
  70.     string $selClips[];
  71.     if ($expClipName != "") {
  72.         $selClips[0] = $expClipName;
  73.     }
  74.     else if ($expClipEditor == "") {
  75.         $selClips = `ls -sl -type animClip`;
  76.     } else {
  77.         string $sel[];
  78.         $sel = `clipEditor -q -sc $expClipEditor`;
  79.         int $selSize = size($sel);
  80.         for ($ii = 0; $ii < $selSize; $ii += 2) {
  81.             string $sch = $sel[$ii];
  82.             int $clipIndex = $sel[$ii+1];
  83.             string $clipName = `clipSchedule -ci $clipIndex -q -n $sch`;
  84.             $selClips[size($selClips)] = $clipName;
  85.         }
  86.     }
  87.     if (size($selClips) == 0) {
  88.         error("Select clips to be exported.");
  89.     }
  90.  
  91.     string $sourceClips[];
  92.     for ($clipName in $selClips) {
  93.         string $sourceClipName = `clip -q -scn $clipName`;
  94.         int $found = 0;
  95.         for ($item in $sourceClips) {
  96.             if ($item == $sourceClipName) {
  97.                 $found = 1;
  98.                 break;
  99.             }
  100.         }
  101.         if (! $found) {
  102.             $sourceClips[size($sourceClips)] = $sourceClipName;
  103.         }
  104.     }
  105.  
  106.     if (size($sourceClips) == 0) {
  107.         error("Found no source clips for the selected clips.");
  108.         return 0;
  109.     }
  110.     
  111.     // save the current selection to restore it at the end
  112.     //
  113.     string $sel[] = `ls -sl`;
  114.  
  115.     // create the command string
  116.     //
  117.     string $result[];
  118.     string $isolateCmd = "clip -isolate";
  119.     string $clipNames = "";
  120.     for ($clip in $sourceClips) {
  121.         $clipNames += (" -name "+$clip);
  122.     }
  123.     $isolateCmd += $clipNames;
  124.     catch($result = eval($isolateCmd));
  125.  
  126.     if (size($result)) {
  127.         select -r $result;
  128.         file -type $fileType -exportSelected -channels true -constructionHistory true $fileName;
  129.         $lib = `ls -type clipLibrary $result`;
  130.         if (size($lib)) {
  131.             delete $lib;
  132.         }
  133.     } else {
  134.         select -r $sel;        
  135.         error("Unable to export. See script editor for details.");
  136.     }
  137.  
  138.     // restore selection
  139.     //
  140.     select -r $sel;
  141.     return 1;
  142. }
  143.  
  144. global proc
  145. doExportClipArgList( string $version, string $args[] )
  146. {
  147.     int $versionNo = $version;
  148.  
  149.     global string $expClipEditor;
  150.     global string $expClipName;
  151.     $expClipEditor  = $args[0];
  152.  
  153.     if ($versionNo > 1) {
  154.         $expClipName  = $args[1];
  155.     } else {
  156.         $expClipName = "";
  157.     }
  158.  
  159.     string $sc[];
  160.     if ($expClipName != "") {
  161.         $sc[0] = $expClipName;
  162.     } else {
  163.         if ($expClipEditor == "") {
  164.             $sc = `ls -sl -type animClip`;
  165.         } else {
  166.             $sc = `clipEditor -q -sc $expClipEditor`;
  167.         }
  168.     }
  169.  
  170.     if (size($sc) == 0) {
  171.         error("Select the clip to be exported.");
  172.     }
  173.  
  174.     string $clipsDir = (`workspace -q -rd`+"clips\/");
  175.     if (`file -q -ex $clipsDir`) {
  176.         workspace -dir $clipsDir;
  177.     }
  178.     // bring up the file browser dialog so that they can choose a file name
  179.     //
  180.     fileBrowser("clipEditorExportClip","Export Clip","ma",1);
  181. }
  182.